package com.dong.es.entity.dtocast.base;

import com.dong.es.entity.EsBaseDTO;
import com.dong.es.entity.EsViewDTO;
import com.dong.es.entity.dtocast.DTOCastMethod;
import com.dong.es.entity.searchparam.page.EsSearchAfterPageParam;

import java.util.List;

/**
 * @description: SearchAfter 分页转换
 * @author: 陈瑞东
 * @create: 2022-07-11 10:23
 */
public class DTOCastSearchAfter extends DTOCastMethod {

    // 每页条数
    private int size;
    // 分页排序
    private List<String> searchAfter;

    @Override
    public boolean isIgnoreNull() {
        return true;
    }

    @Override
    protected Integer sizeLimit() {
        return 2;
    }

    @Override
    protected Class[] typeLimit() {
        return new Class[]{Integer.class, List.class};
    }

    @Override
    protected void doCast(EsViewDTO viewDTO, EsBaseDTO baseDTO) {
        new EsSearchAfterPageParam(size, searchAfter).addTo(baseDTO);
    }

    @Override
    protected void load(Object... args) {
        int size = Integer.parseInt(args[0].toString());
        List<String> searchAfter = (List<String>)args[1];

        this.size = size;
        this.searchAfter = searchAfter;
    }
}
